#
# @lc app=leetcode.cn id=206 lang=python3
#
# [206] 反转链表
#
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
# @lc code=start
# Definition for singly-linked list.

class Solution:
    def reverseList(self, head: ListNode) -> ListNode:
        if head is None:
            return None
        newHead = ListNode(head.val)
        temp = head.next
        while temp is not None:
            node = ListNode(temp.val, newHead)
            newHead = node
            temp = temp.next
        return newHead
# @lc code=end

